]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
js: Use Shell.util_spawn_async functions to launch external processes
authorMarco Trevisan (Treviño) <mail@3v1n0.net>
Tue, 30 Apr 2024 23:14:43 +0000 (01:14 +0200)
committerMarge Bot <marge-bot@gnome.org>
Fri, 24 May 2024 22:48:53 +0000 (22:48 +0000)
As explained in previous commits, it's not safe to use JS code in child
function callbacks, so let's use the safer version of it.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6698
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3293>

js/misc/ibusManager.js
js/misc/util.js
js/ui/components/networkAgent.js

index c3022aaa6d13b3ecf87b97b5230d916aa382247a..6a5158779b75ec9d9995d6df09166348c64b4777 100644 (file)
@@ -115,16 +115,9 @@ class IBusManager extends Signals.EventEmitter {
             const env = launchContext.get_environment();
             // Use DO_NOT_REAP_CHILD to avoid adouble-fork internally
             // since ibus-daemon refuses to start with init as its parent.
-            const [success_, pid] = GLib.spawn_async(
+            const pid = Shell.util_spawn_async(
                 null, cmdLine, env,
-                GLib.SpawnFlags.SEARCH_PATH | GLib.SpawnFlags.DO_NOT_REAP_CHILD,
-                () => {
-                    try {
-                        global.context.restore_rlimit_nofile();
-                    } catch (err) {
-                    }
-                }
-            );
+                GLib.SpawnFlags.SEARCH_PATH | GLib.SpawnFlags.DO_NOT_REAP_CHILD);
             GLib.child_watch_add(
                 GLib.PRIORITY_DEFAULT,
                 pid,
index 4c172988afb0a449f74fd7bdc066532b5e964f30..ca59d36bec3dd5f65a8133a1ad0b442ce80af944 100644 (file)
@@ -118,19 +118,12 @@ export function spawnApp(argv) {
  * this will throw an error.
  */
 export function trySpawn(argv) {
-    let success_, pid;
+    let pid;
     try {
         const launchContext = global.create_app_launch_context(0, -1);
-        [success_, pid] = GLib.spawn_async(
+        pid = Shell.util_spawn_async(
             null, argv, launchContext.get_environment(),
-            GLib.SpawnFlags.SEARCH_PATH | GLib.SpawnFlags.DO_NOT_REAP_CHILD,
-            () => {
-                try {
-                    global.context.restore_rlimit_nofile();
-                } catch (err) {
-                }
-            }
-        );
+            GLib.SpawnFlags.SEARCH_PATH | GLib.SpawnFlags.DO_NOT_REAP_CHILD);
     } catch (err) {
         /* Rewrite the error in case of ENOENT */
         if (err.matches(GLib.SpawnError, GLib.SpawnError.NOENT)) {
index f6d5e1a3f1f3c29e7c7a534f751e3fa048b95c6c..30695901a3ceff85e4a9e167f93543ed6723efe5 100644 (file)
@@ -456,18 +456,12 @@ class VPNRequestHandler extends Signals.EventEmitter {
 
         try {
             const launchContext = global.create_app_launch_context(0, -1);
-            let [success_, pid, stdin, stdout, stderr] =
-                GLib.spawn_async_with_pipes(
+            let [pid, stdin, stdout, stderr] =
+                Shell.util_spawn_async_with_pipes(
                     null, /* pwd */
                     argv,
                     launchContext.get_environment(),
-                    GLib.SpawnFlags.DO_NOT_REAP_CHILD,
-                    () => {
-                        try {
-                            global.context.restore_rlimit_nofile();
-                        } catch (err) {
-                        }
-                    });
+                    GLib.SpawnFlags.DO_NOT_REAP_CHILD);
 
             this._childPid = pid;
             this._stdin = new GioUnix.OutputStream({fd: stdin, close_fd: true});